package com.example.demo.schedule;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.thymeleaf.expression.Dates;

import java.util.Date;

/**
 * Created by hongzhenyue on 18/3/6.
 */
@Component
public class Jobs {
    public final static long ONE_Minute = 60 * 1000;

    @Scheduled(fixedDelay = ONE_Minute)
    public void fixedDelayJob() {
        System.out.println(new Date() + " >>fixedDelay执行....");
    }

    @Scheduled(fixedRate = ONE_Minute)
    public void fixedRateJob() {
        System.out.println(new Date() + " >>fixedRate执行....");
    }

    //    每天的3点15分执行
    @Scheduled(cron = "0 15 3 * * ?")
    public void cronJob() {
        System.out.println(new Date() + " >>cron执行....");
    }

}
